package com.infoland.afanmall.model.fuPin.adapter;

import android.support.annotation.Nullable;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.infoland.afanmall.R;
import com.infoland.afanmall.base.util.ToolsKit;
import com.infoland.afanmall.model.fuPin.entity.FuPinCunResponse;
import com.infoland.afanmall.model.fuPin.entity.FuPinGuanPageResponse;

import java.util.List;

/**
 * @author 王永吉
 * @date 2018/7/2 15:06
 * 扶贫村适配器
 */
public class FpCityActivityAdapter extends BaseQuickAdapter<FuPinGuanPageResponse.ObjectBean, BaseViewHolder> {

    public FpCityActivityAdapter(int layoutResId, @Nullable List<FuPinGuanPageResponse.ObjectBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, FuPinGuanPageResponse.ObjectBean item) {
        try {
            helper.setText(R.id.fu_pin_city_txt1, item.getProvince_name());
            JSONArray jsonArray = JSONArray.parseArray(item.getPromotion_data());
            JSONObject oCun = (JSONObject) jsonArray.get(0);
            helper.setText(R.id.fu_pin_city_txt2, oCun.get("key") + "");
            helper.setText(R.id.fu_pin_city_txt3, oCun.get("value") + "");
            JSONObject oHeZuoShe = (JSONObject) jsonArray.get(1);
            helper.setText(R.id.fu_pin_city_txt5, oHeZuoShe.get("key") + "");
            helper.setText(R.id.fu_pin_city_txt6, oHeZuoShe.get("value") + "");
            ToolsKit.setImgView(item.getPromotion_image_url(), helper.getView(R.id.fu_pin_city_img));
        } catch (Exception e) {

        }

    }
}
